/*java jdk 1.7+
# -*- coding: utf-8 -
'''
Created on 2022年10月12日
@author: zxyong 13738196011
'''*/

package com.plugins.demo;

import javax.websocket.Session;

import org.json.JSONException;
import org.json.JSONObject;

import com.zxy.main.WebSocketUtils;

//webSocket插件包
public class TestWebSocket_IN_CLASS_Demo implements com.zxy.common.ParamName_InterFace
{
	//输入输出信息
	public StringBuilder	strResult		= new StringBuilder();
	public String			strIP			= null;
	public String			userid			= null;
	public String			session_id		= null;
	public Session			inputsession	= null;

	@Override
	public void init_start()
	{
		System.out.println("web Socket接收前端页面发送数据==>"+strResult);
		
		//接收到页面指令
		if(strResult.toString().equals("##001##"))
		{
			JSONObject jso = new JSONObject();
			try
			{
				jso.put("cmd_value","server open success");
			}
			catch(JSONException e)
			{
			}
			//通过websocket发送数据到前端页面
//			boolean bResult = WebSocketUtils.sendMessage("发送websocket数据到页面==>");
			
			//返回到客户端数据
			strResult.delete(0,strResult.length());
			strResult.append(jso.toString());
		}
	}

	public StringBuilder getStrResult()
	{
		return strResult;
	}

	public void setStrResult(StringBuilder strResult)
	{
		this.strResult = strResult;
	}

	public String getStrIP()
	{
		return strIP;
	}

	public void setStrIP(String strIP)
	{
		this.strIP = strIP;
	}

	public String getUserid()
	{
		return userid;
	}

	public void setUserid(String userid)
	{
		this.userid = userid;
	}

	public String getSession_id()
	{
		return session_id;
	}

	public void setSession_id(String session_id)
	{
		this.session_id = session_id;
	}

	public Session getInputsession()
	{
		return inputsession;
	}

	public void setInputsession(Session inputsession)
	{
		this.inputsession = inputsession;
	}
}